import { Form, Input, Button, Tabs } from 'antd';
import React, { useEffect, useState } from 'react';
import Plan from '../promotion/plan/index';
import Advert from '../promotion/advert/index';
import Sift from '../promotion/component/sift';
import { planListSelectedFn } from '@/apis/advert';

const { TabPane } = Tabs;

function callback() {}

export default function promotion(props: any) {
  const [siftList, setsiftList] = useState<[]>([]);
  const [Tabtype, setTabtype] = useState<string>('plan');
  
  const type = props.location.state ? props.location.state.type : '';
  
  useEffect(() => {
    
    planListSelectedFn().then((res: any) => {
      setsiftList(res);
    });
    return () => {};
  }, []);

  function onchange(val: string) {
    setTabtype(val);
  }

  return (
    <div>
      <Tabs defaultActiveKey={type} onChange={onchange}>
        <TabPane tab="计划" key="plan">
          <Sift tabtype={Tabtype} list={siftList}>
            <Plan></Plan>
          </Sift>
        </TabPane>
        <TabPane tab="广告" key="advert">
          <Sift tabtype={Tabtype} list={siftList}>
            <Advert></Advert>
          </Sift>
        </TabPane>
        <TabPane tab="创意" key="creative">
          Content of Tab Pane 3
        </TabPane>
      </Tabs>
    </div>
  );
}
